package com.campus.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.campus.pojos.domain.ClientArticle;
import com.campus.pojos.domain.dto.AdminArticlePageQueryDTO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.HashMap;

@Mapper
public interface ArticleMapper extends BaseMapper<ClientArticle> {
    /**
     * 编辑帖子
     * @param article
     */
    void edit(ClientArticle article);

    /**
     * 管理端条件查询帖子
     * @param dto
     * @return
     */
    Page<ClientArticle> pageQuery(AdminArticlePageQueryDTO dto);


    /**
     * 统计数量
     * @param stTime
     * @param edTime
     * @return
     */
    @Select("SELECT COUNT(*) FROM client_article WHERE create_time BETWEEN #{stTime} AND #{edTime}")
    Integer count(LocalDateTime stTime, LocalDateTime edTime);

    Integer sumByMap(HashMap map);
}
